#ifndef RecePkgManage_H
#define RecePkgManage_H

#include <QMap>
#include <QList>
#include <QDebug>

#include "environment.h"


typedef struct FILEPKGSTRUCT{
    int start;
    int end;
    qint64 startPos;
    qint64 endPos;
}FilePkgStruct;



class RecePkgManage
{
public:
    RecePkgManage(QObject *parent);

    bool addRecePkg(const int pkgNum, const qint64 position);

    bool initRecePkgManage(int count);
    bool initRecePkgManage(const int count, const QList<FilePkgStruct>& list);


    QList<FilePkgStruct> getunRecePkgList();

    int getUnRecePkgListCount() const;
    int getRecePkgCount() const;


private:
    QList<FilePkgStruct> unRecePkgList;
    QList<int> startList;
    int pkgCount;

    int hadReceCount;           //收到包的数量

    qint64 startPos;            //开始文件位置
    qint64 endPos;
    int recePkgStartNum;        //收到文件包开始包号
    int recePkgEndNum;          //收到文件包结束包号

private:
    void init();
    void sortUnRecePkgList(const FilePkgStruct& recePkgStruct);

};

#endif // RecePkgManage_H
